package com.godaiyu.lagou.service;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Component;

@Component
public class ParallelRpcMethodTransfer {

    @Reference
    private TimeSleepService helloService;

    public String parallelRun(String name, int timeToWait) {
        for (int i = 0; i < 20; i++) {
            new Thread(() -> {
                while (true) {
                    String res = helloService.sleepA(name, timeToWait);
//                    System.out.println(res);
                }
            }).start();
        }

        for (int i = 0; i < 20; i++) {
            new Thread(() -> {
                while (true) {
                    String res = helloService.sleepB(name, timeToWait);
//                    System.out.println(res);
                }
            }).start();
        }

        for (int i = 0; i < 20; i++) {
            new Thread(() -> {
                while (true) {
                    String res = helloService.sleepC(name, timeToWait);
//                    System.out.println(res);
                }
            }).start();
        }

        return null;
    }

}
